<?php 
require_once("Response.php");
$response = new Response();
$link = create_connection();

class User
{
	public $id;
	public $type;
}

$sql="select * from qtype";
$result=@execute_sql($link,'zhihu',$sql);
if($result) {
	$data = array();//初始化数组;
    while ($row = mysqli_fetch_assoc($result)) {
		$alter = new User();//实例化对象;
		$alter->id = $row['id'];
		$alter->type = $row['type'];
		$data[] = $alter;
	}
	$response->code = 200;
	$response->message = "success";
	$response->data = $data;
	echo json_encode($response);
} else {
	$response->code = 404;
	$response->message = "error";
	echo json_encode($response);
}

?>